Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Player Trips on Another Player's Head Who Has a Tool? [Filtering-Enabled]

I'm basically stuck since the script won't function due to the pcall. I keep it there just in case the script breaks, or the player leaves. Basically if a player jumps on another player's head while having a tool, the PlatformStand value will turn true. All of this is located in the tool.

Server Script:

local tool = script.Parent
local Events = tool:WaitForChild("Events")
local ChangeCourt = Events:WaitForChild("Foul")

local debounce = true

local function onChangeCourt(Player, hit) -- hopefully i defined it correctly
	local person = hit.Parent; local player = game.Players:FindFirstChild(person.Name)
	if debounce and player and Player.Character:FindFirstChild('VBL_Ball') and Player.Character.VBL_Ball:FindFirstChild('NoFoul') and Player.Character.VBL_Ball.NoFoul.Value == false then
		if hit.Name == 'Right Leg' or hit.Name == 'Left Leg' then
			debounce = false
			pcall(function() person.Humanoid.PlatformStand = true end) --here
			wait(2)
			pcall(function() person.Humanoid.PlatformStand = false end)
			wait(1)
			debounce = true
			repeat wait() until not Player.Character:FindFirstChild('VBL_Ball')
			repeat wait() until debounce
			script:Destroy()
		end
	end
end

ChangeCourt.OnServerEvent:Connect(onChangeCourt)

LocalScript:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()

local foul = character:WaitForChild("Foul")

local tool = script.Parent
local events = tool:WaitForChild("Events")
local foulevent = events:WaitForChild("Foul")

foul.Touched:Connect(function(hit)
	foulevent:FireServer(hit) -- don't know if this Touched function works whilst in a localscript.
end)

I'm uncertain on how this script is suppose to function, but if it's wrong, hopefully there's a solution.

Original Script (ServerScript):

--[[
	/// Script Made By: Jokes4LIFEx \\\
	Dont be a bum and claim ownership...
--]]

local Player = script.Parent.Parent
local debounce = true

repeat wait() until Player.Character

Player.Character:WaitForChild('Head')
wait(0.01)

Player.Character.Head.Touched:connect(function(hit)
	local person = hit.Parent; local player = game.Players:FindFirstChild(person.Name)
	if debounce and player and Player.Character:FindFirstChild('VBL_Ball') and Player.Character.VBL_Ball:FindFirstChild('NoFoul') and Player.Character.VBL_Ball.NoFoul.Value == false then
		if hit.Name == 'Left Leg' or hit.Name == 'Right Leg' then
			debounce = false
			pcall(function() person.Humanoid.PlatformStand = true end)
			wait(2)
			pcall(function() person.Humanoid.PlatformStand = false end)
			wait(1)
			debounce = true
		end
	end
end)

repeat wait() until not Player.Character:FindFirstChild('VBL_Ball')
repeat wait() until debounce
script:Destroy()

Thanks,

LukeGabrieI

1 answer

✓ Accepted answer

Client Script:

-- // Variables
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild('Humanoid')

local FoulEvent = events:WaitForChild('Foul')

function onTouched(hit)
	if hit:IsA('BasePart') and (Humanoid.Jumping) then 
		if (hit.Name == 'Head') and (not Humanoid.PlatformStanding) then 
			FoulEvent:FireServer(Humanoid)
			print('touched head')
		end
	end
end

Character['Right Leg'].Touched:connect(onTouched)
Character['Left Leg'].Touched:connect(onTouched)

Server Script:

local FoulEvent = events:WaitForChild('Foul')

-- // Foul Event Function

function Trip(player, humanoid)
	delay(0, function() -- prevents the loop from interfering
		while humanoid then -- like pcall
			humanoid.PlatformStand = true 
			wait()
		end
	end)
end

FoulEvent.OnServerEvent:connect(Trip)

1 comment

0

Set's the LocalPlayer's PlatformStand to true if they touched a part named, "Head", with their Right or Left Leg.

This discussion is preserved as it was. New answers, comments, and votes are closed.