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

How to fix LocalScript not working even when disabled is set to false?

I have two scripts named "ColorChange" and "Script", "Script" is only executed when "ColorChange" is executed, this is what contains inside "ColorChange":

local pad = script.Parent

function onTouch(hit) 
local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
if user ~= nil then 
pad.BrickColor = user.TeamColor 

end 
end 

script.Parent.Touched:connect(onTouch) 

This is what then contains inside "Script":

local function trigger()
	game.StarterGui.ScreenGui.TextButton.LocalScript.Disabled = false
	
end

game.Workspace.A.Changed:Connect(trigger)

"Script" is supposed to enable the LocalScript inside the TextButton once "ColorChange" changes the BrickColor of the part, the TextButton is a teleportation Button of which when a player presses the TextButton, they are teleported to the designated part (The part's name is A)

But there's one issue I am facing, even when the LocalScript is successfully enabled, the player won't teleport to the designated part when the button is pressed, how do I fix this?

Here's a video about the issue I am currently facing: https://gyazo.com/ecb4f1154705a87ba7f8754c1892eb92

3 comments

0

You are attempting to disable the script from ScreenGui, which is the replicator of UIs, and not the UI itself. In order to disable the script correctly you have to access the UI via PlayerGui, which is found inside the player and can be fetched using Player.PlayerGui.

0

Sorry but I've just started scripting a week ago and this looks a little advanced for me, I tried to study what PlayerGui is and how to access it but I still cannot comprehend what I am reading, would it involve RemoteEvents in order for what you're saying to work?

0

RemoteEvents are used for the client to communicate with the server or the opposite

1 answer

✓ Accepted answer
  1. StarterGui is what you start with. you would have to look for it inside player.playerGui

  2. that doesn't matter in the first place as you cannot enable a local script with a server script. Try using a RemoteEvent

1 comment

0

Tried doing this and it somehow worked while I was re-learning what RemoteEvents are for the 6th time, thanks!

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