This LocalScript is located in StarterGui.ScreenGui.ImageButton.Frame.TextButton
script.Parent.MouseButton1Click:Connect(function() game:WaitForChild("EmoteFreeze", 2) local emotelimit = workspace.Parent.EmoteFreeze if emotelimit.Disabled == false then emotelimit.Disabled = true else emotelimit.Disabled = false end wait(0.1) emotelimit.Disabled = false end)
The script above activates this LocalScript, location in StarterCharacterScripts
local human = script.Parent.Humanoid human.AutoRotate = false human.WalkSpeed = 0 human.JumpPower = 0 wait(3) human.AutoRotate = true human.WalkSpeed = 12 human.JumpPower = 20
It basically freezes my character so it cannot move or rotate, and when I clicked the button it tells me this in the output "EmoteFreeze is not a valid member of DataModel"
And this is the working script, but I think it only activates for me:
script.Parent.MouseButton1Click:Connect(function() game:WaitForChild("EmoteFreeze", 2) local emotelimit = workspace.Aldovy.EmoteFreeze if emotelimit.Disabled == false then emotelimit.Disabled = true else emotelimit.Disabled = false end wait(0.1) emotelimit.Disabled = false end)
So I need to change "workspace.Parent.EmoteFreeze" into "workspace.Aldovy.EmoteFreeze" with my name in it? I don't think that will work with other player in the server. please someone, help me :]
And here is the first localscript i made, located in the button
game.workspace:WaitForChild("Humanoid", 1) local human = game.workspace.Aldovy.Humanoid script.Parent.MouseButton1Click:Connect(function() if human.AutoRotate == true then human.AutoRotate = false else human.AutoRotate = true end if human.WalkSpeed == 10 then human.WalkSpeed = 0 else human.WalkSpeed = 10 end if human.JumpPower == 20 then human.JumpPower = 0 else human.JumpPower = 20 end wait(3) human.AutoRotate = true human.WalkSpeed = 10 human.JumpPower = 20 end)
The descendants of StarterCharacterScripts
are parented to the Player's character every time it is loaded. Characters are located inside Workspace. You're waiting for a maximum for 2 seconds for the EmoteFreeze LocalScript to appear directly inside Workspace. Instead, it is going to appear inside the Player's character; after 2 seconds, the script will throw an error. So how do we get the character?
When you're working with LocalScripts, you can get the local player with Players.LocalPlayer
. This property is assigned to the Player that belongs to the client. Player.Character
is assigned to the character of the Player. If the character does not exist, this property will be nil
.
With this in mind, let's fix your script:
local players = game:GetService("Players") local local_player = players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() -- Check if the character doesn't exist. local character = local_player.Character if not character then return end -- Check if the EmoteFreeze LocalScript hasn't loaded. local emote_freeze = character:FindFirstChild("EmoteFreeze") if not emote_freeze then return end -- not true <--> false, not false <--> true emote_freeze.Disabled = not emote_freeze.Disabled wait(0.1) emote_freeze.Disabled = false end)
I hope that this helped!