Whenever I change the owner value of the car, the name does not update. No errors display in output, the print doesn’t even fire for a value changing. Here is the updater code:
script.Parent.Owner:GetPropertyChangedSignal("Value"):Connect(function()
local pname = script.Parent.Owner
print("e")
if game.Players:FindFirstChild(pname.Value) then
local player = game.Players:FindFirstChild(pname.Value)
script.Parent.Name = "".. player.DisplayName .."'s car"
end
end)
They are both server scripts. I can elaborate as necessary. When I used prints for the owner value being set, it did run the print but no updater print.
Is this a local script or a sever script? Also, if it is a server script, and you’re changing the value client sided, the server will not see that. You’ll need to use RemoteEvents in that case.
I think you’re confused… The first script is a separate server script inside the car. The second snippet is inside my admin commands server script. The second part runs fine and the car spawns, however the first script’s property change signal won’t update by the second snippet (that runs every time it’s activated). It will not update and I do not know why.
I know that the second part works fine. I was saying that in the first part, where you check when the value changes, where do you change the value of that Owner StringValue? Like client or server-sided?
--//Services
local Players = game:GetService("Players")
--//Functions
script.Parent.Owner:GetPropertyChangedSignal("Value"):Connect(function()
local player = Players:FindFirstChild(script.Parent.Owner.Value)
print(player and "Successful" or "Could not find player")
if player then
script.Parent.Name = "".. player.DisplayName .."'s car"
end
end)
Hey so I used Arid’s objectvalue thing and it printed me E but not much else. I changed it to stringvalue and it worked! Here is the full code if you just want to look at it
findclosestthing:
local function findclosestthing(stm, thing) --stm means "string to match" noob
stm = removespaces(stm)
for _, item in pairs(thing:GetChildren()) do
if item.Name:lower():match('^'.. stm:lower()) then
return item
end
end
return nil
end
commands.car:
commands.car = function(sender, arg)
local target = arg[1]
local car = arg[2]
local ftarget = findclosestthing(target, Players)
local fcar = findclosestthing(car, ServerStorage:WaitForChild("Cars"))
local char = ftarget.Character or ftarget.CharacterAdded:Wait()
if char:FindFirstChildWhichIsA("Humanoid").Health > 0 then
local newgun = fcar:Clone()
newgun.Parent = workspace.Map.Misc.cars
newgun.Owner.Value = ftarget.Name
newgun:PivotTo(char:GetPivot() + Vector3.new(0,3,-7.5))
end
end