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

[SOLVED] Server thinks I'm referring to the Player Even tho I'm referring to the character...?

Asked by 3 years ago
Edited 3 years ago
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Mouse = Player:GetMouse()

Mouse.Button1Down:Connect(function()
    if Mouse.Target.Parent:FindFirstChild("Humanoid")then
        print("Mouse.Target ==" ..Mouse.Target.Name)
        local Distance = (Character.HumanoidRootPart.Position - Mouse.Target.Parent.HumanoidRootPart.Position).magnitude
        if Distance <= 20 then
            print(Distance)
            local OtherPlr = Mouse.Target.Parent
            game.ReplicatedStorage.Grab:FireServer(Player,OtherPlr)
        end
    else
        print("Mouse.Target ==" ..Mouse.Target.Name)
    end
end)

alr so I'm trying to make a script that teleports a player to the player that clicked him, but it doesn't seem to work and It's even confusing, above is the LocalScript in the StarterPack, and below is the ServerScript

game.ReplicatedStorage.Grab.OnServerEvent:Connect(function(Player,OtherPlr)
    OtherPlr.HumanoidRootPart.Position = Player.Character.HumanoidRootPart.Position
end)

The error I'm getting is HumanoidRootPart is not a valid member of Player "Players.Player1"

Seems like it thinks that I'm referring to the player itself but I'm referring to the character... any knows why it gives me that error?

1 answer

Log in to vote
0
Answered by 3 years ago

I did an oopise and I fired the event with "Player" in there

 game.ReplicatedStorage.Grab:FireServer(Player,OtherPlr)

i just removed the Player and it worked.

1
put [solved] in the title and don't delete your post. will help future scripters AbsurdAwesome101 56 — 3y
Ad

Answer this question