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

My script is not working after I press the gui, and not outputting errors. Help?

Asked by 5 years ago

Regular Script

game.ReplicatedStorage.Wall.OnServerEvent:Connect(function(player,button)

    --//Variables\\--

   local replicated = game.ReplicatedStorage

   local wall = replicated.BrickWall:Clone()

   wall.Parent = game.Workspace

    for i = 0,6,0.1 do

        wall.CFrame = wall.CFrame * CFrame.new(0,i,0)

        wait()

    end

end)

Local Script

wait()

--//Variables\\--



local player = game:GetService("Players").LocalPlayer

local RemoteEvent = game.ReplicatedStorage.Wall

local button = game.Workspace.StarterGui.ScreenGui.TextButton



button.MouseButton1Click:Connect(function()

RemoteEvent:FireServer()

end)

I'm trying to make a wall/shield type thing that spawns when you click the gui and comes up from the ground.

1 answer

Log in to vote
0
Answered by 5 years ago

StarterGui is NOT where you should be applying events.

StarterGui just clones the all objects parented to it into LocalPlayer.PlayerGui, in this case it would be your ScreenGui.

It would rather be:

local button = LocalPlayer.PlayerGui.ScreenGui.TextButton

Everything else seems fine. Good luck with your project!

Ad

Answer this question