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

? I need help with an error that is possibly easy error

local Spawns = game.Workspace.Spawns:GetChildren()
local player = script.Parent.Parent.Parent.Parent
local TeleportPart = game.Workspace.Cartps.CarTP1

script.Parent.Parent.Parent.Parent.MouseButton1Click:Connect(function()
    player.Character.Humanoid.Sit = false
    wait(0.4)
    player.PlayerGui.ExitGui:Destroy()
    player.Character.HumanoidRootPart.CFrame = Spawns[math.random(1,9)].CFrame
    player.Character.Humanoid.JumpPower = 50
    player.Character.Humanoid.WalkSpeed = 16
end)

I have the script above, I would like to make it work seeing as I get an error due to an old friends error, I no longer have contacts with. The error I get may be quite obvious but I will still post it.

MouseButton1Click is not a valid member of DataModel "Creepy :) @ 24 Nov 2021 21:28"

1 comment

0

script.Parent.Parent.Parent.Parent is referring to the game object, whose class is DataModel. Your error is basically saying MouseButton1Click isn't a function of the game. You'll have to provide more info in order for us to provide a valid answer, though.

1 answer

On line "05" replace it with this:

	player.Parent.MouseClick:Connect(function()

Although I would recommend, using it in this way as I always do it like this:

function Clicked()
	player.Character.Humanoid.Sit = false
	wait(0.4)
	player.PlayerGui.ExitGui:Destroy()
	player.Character.HumanoidRootPart.CFrame = Spawns[math.random(1,9)].CFrame
	player.Character.Humanoid.JumpPower = 50
	player.Character.Humanoid.WalkSpeed = 16
end

player.Parent.MouseClick:Connect(Clicked)

I wish I helped!

1 comment

0

That isn't what the error is saying. MouseButton1Click isn't a member of the game object.

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