MouseButton1Click does not have a parameter called hit that returns the player's character. You need to access the player's character by using game.Players.LocalPlayer.CharacterAdded: Wait(). Here's an example:
local char = game.Players.LocalPlayer.CharacterAdded:Wait()
script.Parent.MouseButton1Click:Connect(function()
char.Position = Vector3.new(-18,0.5,-9)
end)
This is only for use in a local script, which will not change anything for the server or the other players.
This is what you use for a normal (server) script:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
script.Parent.MouseButton1Click:Connect(function()
character.HumanoidRootPart.CFrame=CFrame.new(Vector3.new(-18,0.5,-9)
end)
end)
end)
This is what you are looking for. Am I correct?
2 comments
Thanks so much! I'm doing the LocalScript version but it doesn't seem to be working. I'm putting a print statement under the function for thee MouseButton1Click event and it's not being run. I wonder why?
Can I see the code specifically to identify what your problem is?