(repost due to old topic dead) Updater script not working

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)

And here is the code changing the owner value:

	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))

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.

1 Like

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.

they are both server scripts as i’ve said in the post… also how am i changing value client sided?

Where do you change the value? In a local script?

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.

Seriously tho, did you even read my post?

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?

Oh my god are you trolling? SERVER SIDED. INSIDE A SERVER SCRIPT. AS I’VE SAID 3 TIMES NOW

Then I’ve got no idea why it does not work. Sorry for the inconvenience.

It’s okay. Sorry for screaming at you I just have no idea why its not working… I’m gonna make a second, more specific post

It’s not that you’re not specific. Maybe try changing the StringValue into an ObjectValue and then set that one’s value to the player instance itself?

Could you try this and tell me what it prints?

--//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)
1 Like

It prints “Could not find player”

Are you sure ftarget exists? If you could also show me the entire code for that, I would be able to understand better.

Is the value of the StringValue correct?

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

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.