script.Parent.Touched:Connect(function(hit)
game:GetService("ReplicatedStorage").TouchedRemote:FireClient(game:GetService("Player").LocalPlayer)
end)
I don’t see why it says the error , does anyone know?
script.Parent.Touched:Connect(function(hit)
game:GetService("ReplicatedStorage").TouchedRemote:FireClient(game:GetService("Player").LocalPlayer)
end)
I don’t see why it says the error , does anyone know?
Should be
game:GetService("Players")
Try making it just game.Players.LocalPlayer
then
Hm nothing changed. Just the same error
What sort of script is it? ______…
Try replacing the line with:
game:GetService("ReplicatedStorage").TouchedRemote:FireClient(game.Players[hit.Parent.Name])
Most likely from that error it means you’re trying to get the localplayer from a server script, which just returns nil
, if you want the player object from a server script, do
game:GetService("Players"):GetPlayerFromCharacter(character)
Where character
is the character of the player. You can get the player through the FindFirstAncestorOfClass
method on the Hit part, passing in "Model"
and then passing that model to the GetPlayerFromCharacter mentioned earlier, if that method returns nil
, then just ignore as it didn’t find a character, otherwise pass the player you got to the FireClient
I want the player object from the client.
I don’t know what your other script is. Please provide the other script where the error is occuring
If you’re trying to get the player from the client then game:GetService("Players").LocalPlayer
is enough, but you’re using a server script from what I could see with those errors,
Also that’s a new error, show the code
Simply because you cant access the local player from the server like that.
local players = game:GetService("Players")
local player = players.LocalPlayer
local Text = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui").TextLabel
local RoatateValue = 23
local camera = game.Workspace.Camera
local cutsenetime = 9
local tweenInfo = TweenInfo.new(
cutsenetime,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local character = player.Character
local TweenService = game:GetService("TweenService")
local generalTween = TweenInfo.new(
0.80,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local info = TweenInfo.new(
.2,
Enum.EasingStyle.Linear, -- The tween style in this case it is Linear
Enum.EasingDirection.InOut, -- EasingDirection
0, -- How many times you want the tween to repeat. If you make it less than 0 it will repeat forever.
true,-- Reverse?
0 -- Delay)
)
local showText = game:GetService("TweenService"):Create(Text, generalTween, {TextTransparency = 0})
local hideText = game:GetService("TweenService"):Create(Text, generalTween, {TextTransparency = 1})
local TweenRight = TweenService:Create(Text, info, {Rotation = RoatateValue })-- Creates the tween with the TweenInfo and what properties you want to change
local tweenLeft = TweenService:Create(Text, info, {Rotation = -RoatateValue })
game:GetService("ReplicatedStorage").TouchedRemote.OnClientEvent:Connect(function(player)
showText:Play()
end)
Try this:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game:GetService("ReplicatedStorage").TouchedRemote:FireClient(game:GetService("Players"):GetPlayerFromCharacter(hit.Parent))
end
end)
[Just in case you forgot, if you provide the player as the first argument in FireClient, that argument is the second on the client call.[ The first is automatically the client there]