I'm trying to make a simple script to make a GUI enable on touching something but I'm having no luck.

At first, this is what I tried:

script.Parent.Touched:connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
        game.Players.LocalPlayer.PlayerGui.BoatGUI.Enabled = true
    end
end)

It's in a local script in a block, I'm not sure why it didn't work because the same line of code (game.Players.LocalPlayer.PlayerGui.BoatGUI.Enabled = false) works in the GUI to make it become invisible when the player first joins.

Next, I tried something with remotes which also didn't work (probably because I'm bad at remotes).

Here is that:

Local script in the same block:

script.Parent.Touched:connect(function(HIT)
    local H = HIT.Parent:FindFirstChild("Humanoid")
    if H then
        game.StarterGui.BoatGUI.TextButton.Script.RemoteFunction:InvokeServer(H.Parent.Name)
    end
end)

The script is in the Gui in StarterGui with a RemoteFunction in the script:

script.RemoteFunction.OnServerInvoke = function(player)
    game.Players[player].PlayerGui.BoatGUI.Enabled = true
end

If someone could fix this or tell me what I was doing wrong I would appreciate it.


######Edit: fixed some indentation

6 comments

0

u have to be kidding me

0

LOL

0

a lotttt of errors.. first of all im pretty sure localscripts dont run inside of blocks.. second of all you shouldnt be using localscripts for damaging.. third of all what are you doing with that onserverinvoke.. should be an onclientevent.. fourth of all dont use startergui.. pretty sure this is a troll but whatever

0

@Imperial - where did I say I was damaging something..?

0

PlayerGui is client-side. You have to use LocalScripts to control GUIs

0

Imperialy as far as I can tell, you're more of a troll than the person posting this question . . . not everyone knows these things yet.