So i did this: LocalScript:
local target = script.Parent.Parent.target.Value local sended = false function send() if sended == false then local timer = tonumber(script.Parent.Time.Text) sended = true game.ReplicatedStorage.JailPlayer:FireServer(timer, target) end end script.Parent.Send.MouseButton1Click:Connect(send) script.Parent.Parent.target.Changed:Connect(function() sended = false end)
ServerScript in SSS:
game.ReplicatedStorage.JailPlayer.OnServerEvent:Connect(function(timer, target) game.Players:FindFirstChild(target).JailTime.Value = timer end)
And the player up here is a nil value ;(
First of all, there's no need to get the player using what you're doing.
When you use FireServer()
, the player is already passed to the server script.
Example
LocalScript
local event = game:GetService("ReplicatedStorage").RemoteEvent event:FireServer()
ServerScript
local event = game:GetService("ReplicatedStorage").RemoteEvent event.OnServerEvent:Connect(function(player) -- player is already defined end
So to fix your problems, simply change your server script to the following. (LocalScript needs no change)
Server Script
game.ReplicatedStorage.JailPlayer.OnServerEvent:Connect(function(player,timer, target) local targetPlayer = game:GetService("Players")[target] targetPlayer.JailTime.Value = timer end)