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

GUI script about changing materials works in studio but not ingame?

Asked by 5 years ago

So this is the local script

script.Parent.MouseButton1Click:Connect((function()
    local location = game.Players.LocalPlayer.PlayerGui.MaterialGui.Frame
    game.ReplicatedStorage.Materials:FireServer(location)
end))

And this is the main script

--Material Handler
game.ReplicatedStorage.Materials.OnServerEvent:Connect(function(player,location)
    location.ScrollingFrame.Visible = true
    location.ScrollingFrame.Close.MouseButton1Click:connect(function()
        location.ScrollingFrame.Visible = false
    end)
    location.ScrollingFrame.SmoothPlastic.MouseButton1Click:connect(function()
        script.Material.Value = "SmoothPlastic"
    end)

    location.ScrollingFrame.Plastic.MouseButton1Click:connect(function()
        script.Material.Value = "Plastic"
    end)

    location.ScrollingFrame.CobbleStone.MouseButton1Click:connect(function()
    script.Material.Value = "Cobblestone"
    end)

    location.ScrollingFrame.Brick.MouseButton1Click:connect(function()
    script.Material.Value = "Brick"
    end)

end)

It works in studio but not in game .Help please

0
I hope you aren't trying to change the script's material... You can't be handling the clicks of GUI on a server script, they have to be handled on a local script. I'm not entirely sure what you are trying to do, but I think if you just moved all the Click Events to the local script and made them fire a RemoteEvent with a parameter for Material.Value, it should work as you intend. Pojoto 329 — 5y
0
Well yes i was trying to change the material of a part through a gui but im new to FE scripting so i dont know alot i only know how to work with remote events a little bit thanks will try jovkon123 17 — 5y
0
Thank you sir it helped me alot and it worked jovkon123 17 — 5y
0
No problem! If you need any more help I'd be happy. Pojoto 329 — 5y

Answer this question