Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 comment

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.

1 answer

✓ Accepted answer

###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

2 comments

0

lol i just realized when i did this i put "Local function" XD

0

8 months later

This discussion is preserved as it was. New answers, comments, and votes are closed.