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

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

Asked by 3 years ago
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"
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. sngnn 274 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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!

0
That isn't what the error is saying. MouseButton1Click isn't a member of the game object. sngnn 274 — 3y
Ad

Answer this question