The location variable is an ObjectValue set to a part, which otherwise works if you reference it on its own, like game.Workspace.Part.CFrame, but for some reason doesn’t work when you reference it like this.
I’ve also tried a string value and searching for that value, but that also causes issues.
This is because you have the mouseTarget variable in front of the location variable. You are only passing one argument over the remote meaning that the mouseTarget variable is receiving the data you want and the location variable isn’t receiving anything because nothing was passed.
Your scripts should look like this:
local location = mouse.Target.Location.Value
mouse.Target.Clickable.RemoteEvent.Value:FireServer(location.CFrame)
game.ReplicatedStorage.RemoteEvents.Teleport.OnServerEvent:Connect(function(player, location)
local character = player.Character
if character then
character:PivotTo(location)
end
end)
First off, capitalize the “HumanoidRootPart” like that as a variable. Second, you should pass the player object inside the FireServer function. And third, use “FindFirstChild” instead of “WaitForChild”, because WaitForChild could result in an infinite error.
Yes, but it doesn’t take much to capitalize it. And I have gotten errors before because I don’t pass the Player object in the initial FireServer, FireClient, etc…
I believe the first one is a LocalScript, try this:
local Player = game.Players.LocalPlayer
local Location = mouse.Target.Location.Value
mouse.Target.Clickable.RemoteEvent.Value:FireServer(Player, Location)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
mouse:GetPropertyChangedSignal("Target"):Connect(function()
local target = mouse.Target
local targetLoc = target:FindFirstChild("Location")
if targetLoc then
mouse.Target.Clickable.RemoteEvent.Value:FireServer(target, targetLoc.Value)
end
end)
game.ReplicatedStorage.RemoteEvents.Teleport.OnServerEvent:Connect(function(player, mouseTarget, location)
local character = player.Character
local hmr = character:WaitForChild("HumanoidRootPart")
hmr.CFrame = location.CFrame
end)
Is “Mouse.Target.Location” an ObjectValue instance?
When doing RemoteEvent:FireServer or RemoteFunction:InvokeServer from the client, you do not need to pass the localplayer as the first argument. Roblox already does that, just make sure your server script is set up correctly.
Note: Relying on the client to tell the server which client (itself) fired the event allows exploiters to masquerade as other players. It’s almost like seeing someone you recognise edit: recognize (as good or bad) but ignoring that fact and asking for their ID card instead which adds unnecessary vulnerability and complication.