Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

local replicatedStorage = game:GetService ( ReplicatedStorage ) - - Find the RemoteEvent instead of waiting for it local remoteEvent = replicatedStorage:FindFirstChild (

local replicatedStorage = game:GetService("ReplicatedStorage")
-- Find the RemoteEvent instead of waiting for it
local remoteEvent = replicatedStorage:FindFirstChild("ShootProjectileEvent")
if not remoteEvent then
error("ShootProjectileEvent not found in ReplicatedStorage.")
return
end
local function onShootProjectile(player, direction, origin)
local projectile = replicatedStorage:FindFirstChild("Blast-Wizard")
if not projectile then
error("Blast-Wizard projectile not found in ReplicatedStorage.")
return
end
local newProjectile = projectile:Clone()
newProjectile.Parent = game.Workspace
newProjectile.Position = origin
-- Server-side logic for projectile behavior
local function onTouched(hit)
local hitHumanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if hitHumanoid and hit.Parent ~= player.Character then
hitHumanoid:TakeDamage(10)-- Adjust the damage as needed
newProjectile:Destroy()
elseif hit.Parent:IsA("Terrain") then
newProjectile:Destroy()
end
end
newProjectile.Touched:Connect(onTouched)
wait(3)
newProjectile:Destroy()
end
remoteEvent.OnServerEvent:Connect(onShootProjectile)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions