I made a giant cancollide transparent brick and I put this script in it
function onTouch()
game.Players.PlayerAdded.Jump = false
end
script.Parent.Touched:connect(onTouch)
I want to make it where once you get out of the transparent brick you can jump again so im guessing i would need to make an if then function? but im not sure.
also I don't know how i would identify the character that the person is playing as, and not everyone in the server
edit:
local script (in starterkit)
local remoteEvent = game.ReplicatedStorage:WaitForChild("ActivateTouch") local Touchends = game.ReplicatedStorage:WaitForChild("Touchend") --When Touched remoteEvent.OnClientEvent:connect(function(player) player.Character.Humanoid.JumpPower = 0 end --When Touchends Touchends.OnClientEvent:connect(function() player.Character.Humanoid.JumpPower = 50 end
script (in workspace)
detecttouch = game.Workspace.nojump --Create remote event on Touched to communicate between server and player scripts(client) local RemoteEvent = instance.new("RemoteEvent") RemoteEvent.Parent = game.WaitForChild("ReplicatedStorage") RemoteEvent.Name = "ActivateTouch" --Create remote event for TouchEnded local RemoteEvent = instance.new("RemoteEvent") Touchends.Parent = game.WaitForChild("ReplicatedStorage") Touchends.Name = "Touchend" --When Touched detecttouch.Touched:connect(function(hit) --get the humanoid (This is how you find for humanoid with an Touched event) humanoid = hit.Parent.FindFirstChild("Humanoid") --Check for humanoid (Only found in players, so that other parts which touch this will not activate this script) if humanoid then local player = hit.Parent.GetPlayerFromCharacter() RemoteEvent:FireClient(player) end end --When Touch ends detecttouch.TouchEnded:connect(function(hit) --Can't delete hit as these are two separate functions humanoid = hit.Parent.FindFirstChild("Humanoid") local player = hit.Parent.GetPlayerFromCharacter() Touchends:FireClient(player) end
Hi there,
So, you would like a script that disables jumping in a part, however, based on your script above, when you set jump to false, the player is still able to jump as that option only can detect if a player is jumping, whereby when the player pressed spacebar, Jump will turn to true before turning back to false. Thus, in order to stop a player from jumping, you should use JumpPower. By default, the player can jump to a JumpPower of 50, So, setting the JumpPower to 0 will force the player to be unable to jump. Additionally, in order to make just a single player do it, you should write your script inside a local script and parent it under StarterPack. Since the StarterPack only loads when the player loads in, the script will only activate when the player joins the game.
If your game is to be not filtering enabled (In experimental mode), server scripts and local scripts will not be able to communicate with each other so I do suggest that you put a remote event such that when on Touch, activate the remote event to the local script.
So here is what your script should look like: I do suggest using filtering enabled to prevent hackers.
Local script:
local detecttouch = game.Workspace.(Part detector's name) --When Touched detecttouch.Touched:connect(function(hit) --get the humanoid (This is how you find for humanoid with an Touched event) humanoid = hit.Parent.FindFirstChild("Humanoid") --Check for humanoid (Only found in players, so that other parts which touch this will not activate this script) if humanoid then humanoid.JumpPower = 0 end end --When Touch ends, allow jumping detecttouch.TouchEnded:connect(function(hit) --Can't delete hit as these are two separate functions humanoid = hit.Parent.FindFirstChild("Humanoid") --Reset to default humanoid.JumpPower = 50 end
Server script:
--Create remote event on Touched to communicate between server and player scripts(client) local RemoteEvent = instance.new("RemoteEvent) RemoteEvent.Parent = game.WaitForChild("ReplicatedStorage") RemoteEvent.Name = "ActivateTouch" --Create remote event for TouchEnded local RemoteEvent = instance.new("RemoteEvent) Touchends.Parent = game.WaitForChild("ReplicatedStorage") Touchends.Name = "Touchend" local detecttouch = game.Workspace.(Part detector's name) --When Touched detecttouch.Touched:connect(function(hit) --get the humanoid (This is how you find for humanoid with an Touched event) humanoid = hit.Parent.FindFirstChild("Humanoid") --Check for humanoid (Only found in players, so that other parts which touch this will not activate this script) if humanoid then local player = hit.Parent.GetPlayerFromCharacter() RemoteEvent:FireClient(player) end end) --When Touch ends detecttouch.TouchEnded:connect(function(hit) --Can't delete hit as these are two separate functions humanoid = hit.Parent.FindFirstChild("Humanoid") local player = hit.Parent.GetPlayerFromCharacter() Touchends:FireClient(player) end)
In localscript:
local remoteEvent = game.ReplicatedStorage:WaitForChild("ActivateTouch") local Touchends = game.ReplicatedStorage:WaitForChild("Touchend") --When Touched remoteEvent.OnClientEvent:connect(function(player) player.Character.Humanoid.JumpPower = 0 end) --When Touchends Touchends.OnClientEvent:connect(function(player) player.Character.Humanoid.JumpPower = 50 end)