#mouse target only being the player

1 messages · Page 1 of 1 (latest)

pseudo aspen
#

i am making a script for buildgn stuffs but the mauses targert is always the player? I dont know why its like that but help would be helpful!

Scripts:

-- this is the local script
script.Parent.Activated:Connect(function(d)
    local Plr = game.Players.LocalPlayer
    local Mouse = Plr:GetMouse()
    script.Parent.Event:FireServer(Plr,Mouse.Target)
end)
-- this is the serverside scirpt
script.Parent.Event.OnServerEvent:Connect(function(plr, Target)
    if Target == nil then print("no mouse") return end
    if Target:HasTag("Defence") then
        local New = Target:Clone()
        New.Parent = workspace
        New.Position += Vector3.new(0,New.Size.Y,0)
        print("Cloned part!")
    else
        print("Part ("..tostring(Target)..") not usable.")
    end
end)
#

target is always player why

cunning hatch
#

Because you're passing the player as the first argument for FireServer

pseudo aspen
#

huh

cunning hatch
#
Client: Fire (X, Y, Z)
Server: Receive (Player, X, Y, Z)
#

The client always automatically passes their player when fire a event to the server.

#

Does that make sense?

pseudo aspen
#

yes