I want to make it so that if a player touches a block then a script targets a player for a players CFrame. Please help.
Thank you!
(script in serverscript service)
local function fireballChallenge()
for i = 1,3 do
for i,player in pairs(game.Players:GetPlayers()) do -- Targets every player but I want it to only target a player that has touched a block
if player.Character then
local fireball = game.ReplicatedStorage.Fireball:Clone()
local fireball2 = game.ReplicatedStorage.Fireball2:Clone()
local fireball3 = game.ReplicatedStorage.Fireball3:Clone()
local fireball4 = game.ReplicatedStorage.Fireball4:Clone()
local fireball5 = game.ReplicatedStorage.Fireball5:Clone()
local target = game.ReplicatedStorage.Target:Clone()
local target2 = game.ReplicatedStorage.Target2:Clone()
local target3 = game.ReplicatedStorage.Target3:Clone()
local target4 = game.ReplicatedStorage.Target4:Clone()
local target5 = game.ReplicatedStorage.Target5:Clone()
target.Parent = game.Workspace
target.CFrame = (player.Character.HumanoidRootPart.CFrame - Vector3.new(0,3,0)) * CFrame.Angles(0,0,math.rad(90))
target2.Parent = game.Workspace
target2.CFrame = (player.Character.HumanoidRootPart.CFrame - Vector3.new(-20,3,0)) * CFrame.Angles(0,0,math.rad(90))
target3.Parent = game.Workspace
target3.CFrame = (player.Character.HumanoidRootPart.CFrame - Vector3.new(20,3,0)) * CFrame.Angles(0,0,math.rad(90))
target4.Parent = game.Workspace
target4.CFrame = (player.Character.HumanoidRootPart.CFrame - Vector3.new(0,3,20)) * CFrame.Angles(0,0,math.rad(90))
target5.Parent = game.Workspace
target5.CFrame = (player.Character.HumanoidRootPart.CFrame - Vector3.new(0,3,-20)) * CFrame.Angles(0,0,math.rad(90))
wait(0.5)
fireball.Parent = game.Workspace
fireball.CFrame = target.CFrame + Vector3.new(0,30,0)
fireball2.Parent = game.Workspace
fireball2.CFrame = target.CFrame + Vector3.new(20,30,0)
fireball3.Parent = game.Workspace
fireball3.CFrame = target.CFrame + Vector3.new(-20,30,0)
fireball4.Parent = game.Workspace
fireball4.CFrame = target.CFrame + Vector3.new(0,30,20)
fireball5.Parent = game.Workspace
fireball5.CFrame = target.CFrame + Vector3.new(0,30,-20)
wait(2)
target:Destroy()
target2:Destroy()
target3:Destroy()
target4:Destroy()
target5:Destroy()
end
end
wait(1)
end
end
while wait(5) do
local spike = game.ReplicatedStorage.Tools.Spikes:Clone()
local spiketarget = game.ReplicatedStorage.Tools.SpikeTargets:Clone()
spiketarget.Parent = game.Workspace
wait(0.5)
spike.Parent = game.Workspace
wait(2)
spike:Destroy()
spiketarget:Destroy()
fireballChallenge()
end
