i cant get this script to work!
the code is
local a = game.Players.LocalPlayer
local b = game.Workspace.fuel
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == “fuel” then
a:kick(“you escaped!”)
end
end)
i cant get this script to work!
the code is
local a = game.Players.LocalPlayer
local b = game.Workspace.fuel
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == “fuel” then
a:kick(“you escaped!”)
end
end)
Local Player Doesn’t exist in server-side scripts, try this:
script.Parent.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
game.Players:GetPlayerFromCharacter(hit.Parent):kick("You Escaped!")
end
end)
im trying to make it when a tool touches the part the player gets kicked.
-- Local script, inside the tool
local kickEvent = game.ReplicatedStorage:WaitForChild('RemoteEvent') -- Location & name of event
script.Parent.Touched:Connect(function(hit)
if hit.Name == 'fuel' then
kickEvent:FireServer()
end
end)
-- Server script, perhaps in ServerScriptService
local kickEvent = game.ReplicatedStorage:WaitForChild('RemoteEvent')
kickEvent.OnServerEvent:Connect(function(player)
player:Kick('You escaped!')
end)
Assuming the player holding the tool is the one getting kicked, this can be done with a LocalScript.
local plr = game.Players.LocalPlayer
local handle = script.Parent
handle.Touched:Connect(function(hit)
if hit.Name == "fuel" then
plr:Kick("You escaped!")
end
end)
Put this in a LocalScript inside the tool’s handle.
Im sorry! Completely overlooked the word tool… Someone else here I believe has your solution.