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

how to show a gui for a player through local script?

hey, I need help with showing a gui for the player. i know it sounds simple and it is, but for some reason every single thing I tried either showed the gui for all players or didn't work.

local myPart = game.Workspace.indicator1
local otherPart = myPart.Touched:Wait()
game.Players.LocalPlayer.PlayerGui.speakng.Enabled = true

here is one of the things I tried. this is all in a localscript located inside a textlabel, then frame, then the actual gui. I am really sorry for this dumb question but I can't find it anywhere and I don't want to continue my game until I get this to work, thank you! (and I know I already asked something like this but none of the answers completely helped me)

also, I want to have multiple indicators, which all broadcast an event when touched. if you try to go touch the indicator again, the event won't broadcast a second time. I am making a tutorial in my game, where the gui comes up when you hit the indicator, but I don't want it to occur if the player decides to go backwards.

1 answer

✓ Accepted answer

You could do this:

local part = --Define this

part.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

	if plr then
		plr.PlayerGui.YourScreenGui.Object.Visible = true
	end
end)

Make this a server script.

I also think you could use a local script, try this:

local part = --PartHere

part.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)

	if plr == game.Players.LocalPlayer then
		plr.PlayerGui.ScreenGui.Enabled = true
	end
end)

put the local script inside of StarterGui, or maybe StarterCharacterScripts.

If you want to make it change the player's walkspeed, or jump power, this should help:

local part = --PartHere

part.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.WalkSpeed = --WalkSpeed here
	end
end)

Make sure the script above is a server script inside of the part, or else it wont work!

6 comments

0

would i make a script for each one of my parts?

0

reload the page, and if you are going to try the server script then yes, but f you are going to use the local script then put it inside of StarterGui or StarterCharacterScripts, inside of StarterPlayer.

0

I am using the second one since that works better for what I am trying to do, but for some reason my simple walkspeed script (game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 0) keeps breaking the code, even though it worked fine before. should i make a new "question" for this? thank you so much

0

here i will edit the script to help you out, hold on.

0

Edited.

0

thank you so much, that helped a lot. the code is now becoming glitchy where the first on-touch event with indicator 1 works, but instead of waiting for the player to touch the second indicator it ignores the line and continues till after. if you don't know what i could do ill just make a new topic and accept this answer. thank you again and i am so sorry for bothering you so much

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