Hi, anyway, I don’t know how stupid this question is, I can’t understand the path of the script that is in StarterCharacterScripts, here is an example I wrote
local scriptToDisable = game.StarterPlayer.StarterCharacterScripts.Script
and I think this is the wrong path because if you move it to workspace and make the path like this local script = worckspace.script then everything will work, but in StarterCharacterScripts it won’t.
The StarterCharacterScripts class stores scripts to be parented in a player’s Player.Character, when they spawn. Unlike scripts stored in the PlayerScripts folder, these scripts will not persist when the player respawns
Sorry guys, I understand that you know how to write this path and you don’t want me to just copy it and paste it into my code, but I’m not an experienced scriptwriter and I have absolutely no idea what you’re talking about, I’ve been thinking for an hour and nothing has worked, sorry. So please just write me the path like that
local script = ...myScript
and I will understand and remember how to do it, thanks
You should learn the basics of how to get the character via the player (or a bit differently). And I am not sure on how you get the character but this would be just an example for your username. This method is completely unreliable.
Also if you want to find the script its under workspace > CHARACTER NAME > script
But like I said, just get the basics of how to get the character, since like i said, this is completely unreliable. You might aswell just get the .LocalPlayer in another Local Script or just use a PlayerAdded Event or really another way to get the player/character.
StarterPlayer is just a folder for you to hold the scripts on the studio.
The scripts that are in StarterPlayer.StarterCharacterScripts goes to inside the player’s character when the game starts.
so basically get the character and then the script, in a localscript
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local scriptToDisable = char:WaitForChild("Script")
To know more about StarterCharacterScripts, I recommend you to read What is the point of StarterCharacterScripts? You might easily understand what StarterCharacterScripts is by reading the Topic and the solution.
As for the code, It would be something like if it's a script
local scriptToDisable = game.Players.Player123.Character.scriptToDisable
player123 is the player that the scriptToDisable is in, so change it to the player name that the script is located in their character model (Everyone has that script so you might want to disable it for everyone when you want to disable the script for everyone)
else get the one from the people above, This code :
Thanks to everyone who is trying to help me, I checked all your codes and tips, but as usual it happens with losers I did not get anything, or rather I got, but badly, I inserted these variables into my code like that:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local scriptToDisable = char:WaitForChild("Script")
I got an error: attempt to index nil with ‘Character’
I realized the reason and changed the usual script to LocalScript, this error disappeared, but nothing changed, my script did not work and does not work, I do not know why, if scriptToDisable moved to Workspace, everything will work.
Let me describe everything in more detail.
Here is the LocalScript that needs to be disabled and is located in StarterPlayer.StarterCharacterScripts:
local player = game.Players.LocalPlayer
local humanoid = player.Character.Humanoid
task.spawn(function()
while true do
humanoid.Jump = true
wait(1)
end
end)
local function onKeyPress(actionName, inputState, input)
if inputState == Enum.UserInputState.Begin and (input.KeyCode == Enum.KeyCode.Space or input.KeyCode == Enum.KeyCode.ButtonA) then
return Enum.ContextActionResult.Sink
end
end
game:GetService("ContextActionService"):BindAction("DisableJump", onKeyPress, false, Enum.KeyCode.Space, Enum.KeyCode.ButtonA)
*(player constantly jumps every second and can’t do anything about it)
And here’s the LocalScript for the part where the previous script is disabled and the player can jump freely:
local zone = workspace.SpawnZone.noJumpZone
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local scriptToDisable = char:WaitForChild("Jump")
local active = true
local function disable() -- Power-off function
print("hi")
scriptToDisable.Disabled = true
active = false
end
local function enable() -- Power-on function
print("bye")
scriptToDisable.Enabled = true
active = true
end
local function Touch(otherpart) -- Player touch the zone
local character = otherpart.Parent
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid and active == true then
disable()
end
end
local function Touchoff(otherpart) -- Player leave the zone
local character = otherpart.Parent
local humanoid = character:FindFirstChildWhichIsA("Humanoid")
if humanoid and active == false then
enable()
end
end
zone.Touched:Connect(Touch)
zone.TouchEnded:Connect(Touchoff)