Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

How do I make this script into ClickDetector and not Mouse1Click?

Asked by 5 years ago

I found this script and used it, but I want it in ClickDetector and not Mouse1Click or MouseEnter. This is the script:

plr = script.Parent.Parent.Parent.Parent

script.Parent.MouseEnter:connect(function()
script.Parent.TextStrokeTransparency=0  
end)

script.Parent.MouseLeave:connect(function()
script.Parent.TextStrokeTransparency=1
end)



script.Parent.MouseButton1Down:connect(function()
local coordinats = plr.Character.Torso.CFrame
plr:LoadCharacter(true)
plr.Character.Torso.CFrame = coordinats
local stuff = plr.Character:GetChildren()

for i = 1,#stuff do
    if stuff[i].ClassName=="ForceField" then
        stuff[i]:Remove()
    end
end

end)
2
Please help me, and thank you for giving me a down vote. i deserve it all the time since I am stupid. User#5689 0 — 5y
0
Check my Comment on an answer that was given. alphawolvess 1784 — 5y

1 answer

Log in to vote
1
Answered by
M39a9am3R 3209 Moderation Voter Community Moderator
5 years ago

Let me see what I can do here...

--I can't do anything about the Hovering Events... Sorry.

script.Parent.MouseClick(function(plr) --Change MouseButton1Down to MouseClick, add plr to the parenthesis after function, since the function can take the player property of who clicked it.
if plr ~= nil and plr.Character:FindFirstChild("Torso") then --Trying to protect the script from breaking, having the script check if the player still exists, and that the Torso is still around.
local coordinats = plr.Character.Torso.CFrame
plr:LoadCharacter(true) --Alright, I look at the API for this, I guess it means if LoadCharacter(InGame) is set to true then it will load your new character appearance as opposed to the old one, it's not really necessary to have this portion of the method.

plr.Character.Torso.CFrame = coordinats --I am not sure if the server will have enough time to respond after that respawn, if it does not teleport the player add a wait function before it.

local stuff = plr.Character:GetChildren()
for i = 1,#stuff do
    if stuff[i].ClassName=="ForceField" then
        stuff[i]:Remove()
    end
end

end
end)

If you have any questions about the script, let me know in the comments section.

I kind of wish people would stop downvoting others without even giving reason, it's happened to me in that past numerous times and one time five of my top rated answers were downvoted by a troll. At least have the common courtesy to give a reason for a down vote people. Thank you.

0
So I can use this script with ClickDetector? User#5689 0 — 5y
0
For a script to work with a ClickDetector, you need to use a part. Not a GUI. This requires you to need to insert a ClickDetector into a part. This script has to be inside of said part. Apparently your script is a free model. What are you trying to do with the free model? Remove FF's? You may set the Duration in SpawnLocation to 0; this makes a player spawn without FF. alphawolvess 1784 — 5y
Ad

Answer this question