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

WHAT DID I DO WRONG?! its supposed to give me a gravity coil?! but it does nothing

Asked by 4 years ago
Edited 4 years ago

WHAT DID I DO WRONG, WHEN I PRESS IT IT'S SUPPOSED TO GIVE ME A GRAVITY COIL?! PLEASE TWEAKKKKK.

script:

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function(click) if player.leaderstats.High Score.Value >= 1 then player.leaderstats.High Score.Value = player.leaderstats.High score - 1

    game.ReplicatedStorage.Tools.GravityCoil:clone().Parent = player:WaitForChild("Backpack")
end

end)

1
can you please edit this and put the full script in the code block. SteamG00B 1633 — 4y
0
It wont let me Haker902c 18 — 4y
0
What do you mean? It won't let you edit? SteamG00B 1633 — 4y
0
it does let me edit but the code block only does a portion of my script for some reason, and the script that is in the code block is just there by default for some reason Haker902c 18 — 4y
View all comments (3 more)
1
You need to fire a remote event. because of the 2017 update for FFE (Force Filtering Enabled), you cannot give commands to the game from a local script. See https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events. Correct me if I am wrong anyone. yourfuturepilot2 -2 — 4y
0
Ok, so you need to remove the block you already have, then highlight all of your code, then press the code block button. SteamG00B 1633 — 4y
0
@ yourfuturepilot2 from what I see there, he is cloning it from replicated storage which is accessible from the client because that is where you store remote events. SteamG00B 1633 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

So. You need to use Remote Events. Because if you're working with GUIs, they have to be LocalScript since they have to be replicated to the PlayerGui. So we're gonna use FireServer() in order to send information. (Make sure your script is below the ScreenGui.)

Local Script

script.Parent.ImageButton:Connect(function()
    local player = game.Players.LocalPlayer
    if player.leaderstats["High Score"].Value >= 1 then
        game.ReplicatedStorage.RemoteEvent:FireServer(player)
    end
end)

Now we just passed data. We only need the player property.

Server Script

game.ReplicatedStorage.OnServerEvent:Connect(function(player)
    player.leaderstats["High Score"].Value = player.leaderstats["High Score"].Value - 1
    local tool = game.ReplicatedStorage.Tools.GravityCoil
    local toolClone = tool:Clone()
    toolClone.Parent = player.Backpack
end)
Ad

Answer this question