So I’m not really good at scripting, but I have trouble with one thing. I wanted to make a script that doesn’t work. It’s supposed to show a message after touching a part, but no matter what I do, it never works.
local Player = game.Players.LocalPlayer
The first 2 is the name of my gui and the last one is the name of the part. I watched a few tutorials yet none of them worked. It’s kinda confusing how there’s not a single mention of the text label. And yes, this script is both in the part and in gui related to it.
One potential mistake I’m seeing is that you aren’t checking whether the object touching “touchpart” is a child of the character. Another problem might be that you are trying to run a local script in the workspace. You can only run local scripts in client based container services, like StarterPlayer or StarterGui.
Let’s start with the fact that it is not advisable to write such things in a local script; they are intended for the server. The cause of the breakdown in your case is FindFirstChild; it does not wait for the part to load, but immediately tries to find it and produces nil if it does not find anything. Use waitForChild instead, here is a code example in your case.
local players = game:GetService("Players")
local localPlayer = players.LocalPlayer
local debounce = false
workspace:WaitForChild("touchpart").Touched:Connect(function(p)
if not debounce and p.Parent:FindFirstChild("Humanoid") then
local player = players:GetPlayerFromCharacter(p.Parent)
if player.Name == localPlayer.Name then
debounce = true
player.PlayerGui.Interactive.Enabled = true
task.wait(5)
player.PlayerGui.Interactive.Enabled = false
task.wait(.5)
debounce = false
end
end
end)
Hello, I’ve faced this issue, the thing is some reason ScreenGUI doesn’t enable back or disables after it’s enabling value has been changed (Script-Wise), idk why but I have also had this issue to fix this just do this:
Create a frame Size = [1, 0], [1, 0]
Parent your textLabel or the thing you want to display under it
Make your frame’s visible property to false, making all parented childs under it to also be not visible
Now change the function to do the following code below to
Make sure that when you post a script. Highlight the entire script and click on the format script button. It should be above where you write. Because only part of your script is showing formated
By the way I see this: game.Workspace:FindFirstChild(“touchpart”).Touched:Connect(OnTouch)
Maybe the function isn’t calling. Maybe put it as instead perhaps?: game.Workspace:FindFirstChild(“touchpart”).Touched:Connect(OnTouch())