Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Change the value inside of the object when the dialog selected?

I want it to like when the player selects the dialogChoice the value named "Owner" inside of the object to change to the players name when selected. hope this isn't to not understandable?

script.Parent.DialogChoiceSelected:connect(function(player, choice)
if choice == script.Parent.Choice1 then
local boat = game.Lighting.yo:clone()
boat.Parent=player.Character
boat:makeJoints()
if boat.Parent.Owner.Value==nil then
boat.Parent.Owner.Value=player.Character.Name
return
end
end
end)

2 comments

1

Hit edit, then put your code in the code block with the 'Lua

0

"hope this isn't to not understandable?" - Doesn't stick it in a code block.

1 answer

✓ Accepted answer

From your description it seems that the "Owner" value is inside the boat, but right now you're trying to find it in player's character due to the boat.Parent.Owner statement.

Also consider using line breaks and tabs. Yes, they aren't necessary and won't affect code functionality, but will make it a lot more readable for yourself and others.

script.Parent.DialogChoiceSelected:connect(function(player, choice) 
	if choice == script.Parent.Choice1 then 
		local boat = game.Lighting.yo:clone()  -- Please don't use lighting as storage anymore, move it to ReplicatedStorage or ServerStorage
		boat.Parent=player.Character -- Note that boat will turn invisible in first person and will get destroyed once player dies. Consider placing it in workspace instead and rely on the Owner value?
		boat:MakeJoints() 

		if  boat.Owner.Value == "" then -- The string value exists by default, so it's not nil. Rather check for empty string
			boat.Owner.Value = player.Name -- No need to use character's name, using player's name would be more reliable
			return 
		end 
	end 
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.