I'm not requesting a full script, I'm just at loss for how to go about this. As of now, this is what I'm pretty sure I know I'll have to do:
However, these are the issues I'm encountering:
Any help possible is greatly appreciated, since this is a bit out of my skill zone, and is one of the last things I have left to code in my newest project.
Thanks for reading!
To fix the biggest problem, you would need to detect if a player actually touches the brick. Like so:
local brick = Workspace.Part function onTouch(part) if part.Parent:FindFirstChild("Humanoid") ~= nil then --Code end end brick.Touched:connect(onTouch)
This detects a humanoid in the parent model of part
using FindFirstChild()
. It should not equal nil if a player touched as the part would equal some body part, and the parent of that should have a humanoid in it.
Now, to find the player's gui screen, make a clone of the script, then move it to the GUI, we would use GetPlayerFromCharacter
and yes, the :Clone()
. Like so:
local brick = Workspace.Part function onTouch(part) if part.Parent:FindFirstChild("Humanoid") ~= nil then local player = game.Players:GetPlayerFromCharacter(part.Parent) local clone = game.Lighting.Script:Clone() --Replace script with the name of your script clone.Parent = player.PlayerGui.ScreenGui --Setting the parent. Change ScreenGui to whatever the name of your GUI is. end end brick.Touched:connect(onTouch)
To make sure it isn't spammed, you would use a debounce value too.
local debounce = false local brick = Workspace.Part function onTouch(part) if part.Parent:FindFirstChild("Humanoid") ~= nil and debounce == false then debounce == true local player = game.Players:GetPlayerFromCharacter(part.Parent) local clone = game.Lighting.Script:Clone() --Replace script with the name of your script clone.Parent = player.PlayerGui.ScreenGui --Setting the parent. Change ScreenGui to whatever the name of your GUI is. wait(1) debounce = false end end brick.Touched:connect(onTouch)
Brick.Touched:connect(function(part) -- This is the event. You seem to be inexperienced with functions, so I'll walk you through it. if game.Players:GetPlayerFromCharacter(part.Parent) then -- This is checking to see if the part belongs to a player's character player = game.Players:GetPlayerFromCharacter(part.Parent) gui = game.Lighting.GuiHere:Clone() -- This clones the GUI you want to insert. gui.Parent = player.PlayerGui -- This makes the GUI visible to the player. (Note: GUI must refer to a StarterGui.) end end)