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

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

Asked by
R0jym 47
2 years ago

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

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. RazzyPlayz 497 — 2y
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? R0jym 47 — 2y
0
RemoteEvents are used for the client to communicate with the server or the opposite RazzyPlayz 497 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
  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

0
Tried doing this and it somehow worked while I was re-learning what RemoteEvents are for the 6th time, thanks! R0jym 47 — 2y
Ad

Answer this question