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

Why doesn't this work?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I have a script that clears all the children from workspace when someone presses "f". Can you help?

If you were going to ask, this IS in a local script.

local lclplr = game.Players.LocalPlayer
local Mouse = lclplr:GetMouse()

Mouse.KeyDown:connect(function(key)

    if key == "f" then
        game.Workspace:ClearAllChildren()

        end
end)

1
Make sure the local script is in StarterGui or StarterPack; I just tested the script and it works. DigitalVeer 1473 — 9y
0
+1 woodengop 1134 — 9y

2 answers

Log in to vote
0
Answered by
woodengop 1134 Moderation Voter
9 years ago

There is Nothing wrong with your Script, Just that it must be in a Localscript, and placed in StarterGui or StarterPack.

if this Helped please accept answer and upvote!

Ad
Log in to vote
-2
Answered by 9 years ago

If you want it to remove the children of Workspace, you probably should make it on Player entered using: game.Players.PlayerAdded:connect(function(Player) end)

And plus, I don't know if this is part of the error, but the if Key == "f" then should probably be if Key:lower() == "f" then

And use this in a regular script.

game.Players.PlayerAdded:connect(function(Player)
    Player:GetMouse().KeyDown:connect(function(Key)
        if Key:lower() == "f" then
            game.Workspace:ClearAllChildren()
        end
    end)
end)
0
doesn't matter if you use the "lower()" woodengop 1134 — 9y
0
You can't getmouse in a server script. FutureWebsiteOwner 270 — 9y

Answer this question