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

Trying to make a part change a scrolling frames transparency to 1 when I touch it?

Asked by
AltNature 169
6 years ago

So When I step on the part it does print yes and yet it doesn't change the transparency?

local function onTouch(hit) game.StarterGui.ScreenGui.ScrollingFrame.BackgroundTransparency = 1 print("yes") end script.Parent.Touched:connect(onTouch)

0
You're editing the StarterGui not the Player's Gui, so edits aren't being shown to you. I can elaborate further if you want me to. PreciseLogic 271 — 6y

1 answer

Log in to vote
2
Answered by 6 years ago

The problem with, your script is, you’re trying to modify a GuiObject on the server. You don’t use StarterGui, you use PlayerGui. You can’t modify PlayerGui from the server either. Use a RemoteEvent to do this.

-- LocalScript under StarterGui/PlayerGui

local remote = game.Workspace.RemoteEvent 
-- I recommend under ReplicatedStorage, but this is an example

remote.OnClientEvent:Connect(function() 
    -- :Connect not :connect, :connect is deprecated

    script.Parent.ScreenGui.ScrollingFrame.BackgroundTransparency = 1
end)

Server code:

function onTouch(part)
    local plr = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)

    if plr then
        game.Workspace.RemoteEvent:FireClient(plr)
    end
end

script.Parent.Touched:Connect(onTouch)
-- Again, :Connect, not :connect
0
lol i just realized when i did this i put "Local function" XD AltNature 169 — 6y
0
8 months later AltNature 169 — 5y
Ad

Answer this question