Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I have something wrong with the MouseButton1Click event, how can i fix it?

Asked by 3 years ago

First, i have a table on the module script, on the script inside the GUI, i set a MouseButton1Click event on the GUI, after clicking, it will teleport us and insert our name to the table, but something went wrong, i expected it will have 1 player on the table but it got more eventhough i just click it one time

Here's my script:

local join = script.Parent
local plrjoin = require(game.ServerStorage.ModuleScript)

game.Workspace.Lobby.Floor.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
        join.Visible = true
        join.MouseButton1Click:Connect(function()
            local LowerTorso = hit.Parent.LowerTorso
            LowerTorso.CFrame = game.Workspace.Lobby.SpawnToTeleportPlace.CFrame
            join.Visible = false

        end)
    end
end)

Also i cant use the LocalScript because i cant use require() on it

0
oops, i forgot the table.insert(plrjoin,1,hit.Parent.Name) at the end, sorry guys ninjaty2003 8 — 3y

1 answer

Log in to vote
0
Answered by
Jo1nts 134
3 years ago

Try this:

local join = script.Parent
local plrjoin = require(game.ServerStorage.ModuleScript)

game.Workspace.Lobby.Floor.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
        join.Visible = true
    end
end)

        join.MouseButton1Click:Connect(function()
    if join.Visible = true then
            local LowerTorso = hit.Parent.LowerTorso
            LowerTorso.CFrame = game.Workspace.Lobby.SpawnToTeleportPlace.CFrame
            join.Visible = false
    end
end)
Ad

Answer this question