Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why will this script only work in Solo?

Asked by 9 years ago

This script only works in Solo Mode.

local Player = game.Players.LocalPlayer
Player.Character.Humanoid.WalkSpeed = 0
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
if string.byte(Key) == 32 then
Player.Character.Humanoid.Health = 0
elseif string.byte(Key) == 120 then
Player.Character.Humanoid.Jump = true
elseif string.byte(Key) == 27 and Player.PlayerGui.ScreenGui.Cheat.Visible == false then
Player.PlayerGui.ScreenGui.Frame.Visible = true
Player.PlayerGui.ScreenGui.Quiter.Visible = false

end
end)

It won't work in Regular Online mode. Help!

EDIT: Whoever Thumbs down this question probably can't script. This is serious though. The whole rage game revolves around this script. It's all glitchy though. Sometimes it works, and other times it doesn't.

EDIT2: Oops, forgot to say this, This script is a LocalScript.

0
https://scriptinghelpers.org/help/how-post-good-questions-answers Make sure you tell us what you're trying to do and also include any output, why it isn't working, what' s happening, etc. Perci1 4988 — 9y
0
I have no idea what is happening. Also there is no output. Except for the "Cutscene Editor Loading". The Cutscene editor is a plug-in. EzraNehemiah_TF2 3552 — 9y

2 answers

Log in to vote
1
Answered by 9 years ago

Someone else had a similar problem earlier:

local Player = game.Players.LocalPlayer

can only be used in a local script. This script needs to be inside a localscript in the player. (Put it in startergui or clone it into the player using :clone() )

0
That isn't the problem. It already is in LocalScript inside of StarterGui. EzraNehemiah_TF2 3552 — 9y
Ad
Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
9 years ago

A lot of times, LocalScripts will try to run before the client has actually loaded, so try adding an empty wait to the top.

wait()
local Player = game.Players.LocalPlayer
Player.Character.Humanoid.WalkSpeed = 0
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(Key)
    if string.byte(Key) == 32 then
        Player.Character.Humanoid.Health = 0
    elseif string.byte(Key) == 120 then
        Player.Character.Humanoid.Jump = true
    elseif string.byte(Key) == 27 and Player.PlayerGui.ScreenGui.Cheat.Visible == false then
        Player.PlayerGui.ScreenGui.Frame.Visible = true
        Player.PlayerGui.ScreenGui.Quiter.Visible = false
    end
end)

Answer this question