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

Spin is not a valid member of PlayerGui ?

Asked by 5 years ago
s = script.Parent

s.ClickDetector.MouseClick:connect(function(p)
local gui = p.PlayerGui
if p.Data.Tries.Value >= 1 and gui then
gui.Spin.Frame.Visible = true
end
end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

The PlayerGui in the Server is not replicated or changeable, so you will either have to use Remote Events and Functions See Here: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

Example:

Server Script

local remote = game.ReplicatedStorage.RemoteEvent
local s = script.Parent

s.ClickDetector.MouseClick:Connect(function(p)
    remote:FireClient(p)
end)

Local Script in StarterGui

local remote = game.ReplicatedStorage.RemoteEvent
local p = game.Players.LocalPlayer

remote.OnClientEvent:Connect(function()
    if p:FindFirstChild("Data") ~= nil and p.Data.Tries.Value >= 1 then
        script.Parent.Spin.Frame.Visible = true
    end
end)

The above example has a Remote Event named "RemoteEvent" in Replicated Storage

OR

Use a LocalScript within StarterGui

local p = game.Players.LocalPlayer
local s = workspace.Part

s.ClickDetector.MouseClick:Connect(function()
    local gui = script.Parent
    if p.Data.Tries.Value >= 1 and gui then
        gui.Spin.Frame.Visible = true
    end
end)

In addition, make sure that "Spin" is under the StarterGui when you start the game.

Ad

Answer this question