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

Why my script works only in studio and not on my sever?

So my script works in studio but when I run it on the server dose't work. how do I fix this code?

thing = nil
function onButton1Down(mouse)
local Hit = mouse.hit
local MT = mouse.target
if Hit==nil then return end
if MT==nil then return end
if MT.Parent:findFirstChild("Humanoid") ~= nil then
thing = MT.Parent.Humanoid
elseif MT.Parent:findFirstChild("Humanoid") ~= nil then
thing = MT.Parent.Zombie
else
if thing ~= nil then
	thing:MoveTo(mouse.hit.p, MT)
end

end
end

function onS(mouse)
mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end
script.Parent.Selected:connect(onS)

1 answer

I'm guessing from the Selected event that this is in a HopperBin; in that case, you should put your code in a LocalScript rather than a regular script. Code in local scripts will run on the client and have access to things like the player's mouse. In studio, most code runs like it's on the client.

1 comment

0

Works thx

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