Answered step by step
Verified Expert Solution
Question
1 Approved Answer
local replicatedStorage = game:GetService ( ReplicatedStorage ) - - Find the RemoteEvent instead of waiting for it local remoteEvent = replicatedStorage:FindFirstChild (
local replicatedStorage game:GetServiceReplicatedStorage Find the RemoteEvent instead of waiting for it local remoteEvent replicatedStorage:FindFirstChildShootProjectileEvent if not remoteEvent then errorShootProjectileEvent not found in ReplicatedStorage." return end local function onShootProjectileplayer direction, origin local projectile replicatedStorage:FindFirstChildBlastWizard" if not projectile then errorBlastWizard projectile not found in ReplicatedStorage." return end local newProjectile projectile:Clone newProjectile.Parent game.Workspace newProjectile.Position origin Serverside logic for projectile behavior local function onTouchedhit local hitHumanoid hit.Parent:FindFirstChildOfClassHumanoid if hitHumanoid and hit.Parent ~ player.Character then hitHumanoid:TakeDamage Adjust the damage as needed newProjectile:Destroy elseif hit.Parent:IsATerrain then newProjectile:Destroy end end newProjectile.Touched:ConnectonTouched wait newProjectile:Destroy end remoteEvent.OnServerEvent:ConnectonShootProjectile
local replicatedStorage game:GetServiceReplicatedStorage
Find the RemoteEvent instead of waiting for it
local remoteEvent replicatedStorage:FindFirstChildShootProjectileEvent
if not remoteEvent then
errorShootProjectileEvent not found in ReplicatedStorage."
return
end
local function onShootProjectileplayer direction, origin
local projectile replicatedStorage:FindFirstChildBlastWizard"
if not projectile then
errorBlastWizard projectile not found in ReplicatedStorage."
return
end
local newProjectile projectile:Clone
newProjectile.Parent game.Workspace
newProjectile.Position origin
Serverside logic for projectile behavior
local function onTouchedhit
local hitHumanoid hit.Parent:FindFirstChildOfClassHumanoid
if hitHumanoid and hit.Parent ~ player.Character then
hitHumanoid:TakeDamage Adjust the damage as needed
newProjectile:Destroy
elseif hit.Parent:IsATerrain then
newProjectile:Destroy
end
end
newProjectile.Touched:ConnectonTouched
wait
newProjectile:Destroy
end
remoteEvent.OnServerEvent:ConnectonShootProjectile
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started