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

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

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

1 comment

0

oops, i forgot the table.insert(plrjoin,1,hit.Parent.Name) at the end, sorry guys

1 answer

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)

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