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?
01 | script.Parent.DialogChoiceSelected:connect( function (player, choice) |
02 | if choice = = script.Parent.Choice 1 then |
03 | local boat = game.Lighting.yo:clone() |
04 | boat.Parent = player.Character |
05 | boat:makeJoints() |
06 | if boat.Parent.Owner.Value = = nil then |
07 | boat.Parent.Owner.Value = player.Character.Name |
08 | return |
09 | end |
10 | end |
11 | end ) |
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.
01 | script.Parent.DialogChoiceSelected:connect( function (player, choice) |
02 | if choice = = script.Parent.Choice 1 then |
03 | local boat = game.Lighting.yo:clone() -- Please don't use lighting as storage anymore, move it to ReplicatedStorage or ServerStorage |
04 | 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? |
05 | boat:MakeJoints() |
06 |
07 | if boat.Owner.Value = = "" then -- The string value exists by default, so it's not nil. Rather check for empty string |
08 | boat.Owner.Value = player.Name -- No need to use character's name, using player's name would be more reliable |
09 | return |
10 | end |
11 | end |
12 | end ) |