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

Value Is Not A Valid Instance Of Model?

HI THANK YOU i have a little problem eatch player can has a vote and they can choose it forms Gui and when they press the buttons an local script is gonna be firing to a script and in that script we store the data in their character and then when they press the button again it delets the old value and replace it with a new here is the script

voteevent.OnServerEvent:Connect(function(plrc,num)
			local votevalue=Instance.new("IntValue")
			votevalue.Name="votevalue"
			votevalue.Value=num
			local playervot=plrc.Character or plrc.CharacterAdded:Wait()
			
			if allow==true and playervot.votevalue then
				print("WE DESTROYES"..playervot.votevalue.Value)
				playervot.votevalue:Destroy()
				
			end	
			votevalue.Parent=playervot
			print(playervot.votevalue.Value)
			allow=true
		end)

and this works fine in single player but when i play it in multiplayer it gives me the error votevalue is not part of model Thank You if u have a Solution please Ansewer.

1 answer

✓ Accepted answer

Howdy!

I think you're having trouble properly indexing the character and dictating where you want the script to look, I recommend using a :FindFirstChild(). Furthermore, I'm not sure you can use a logic operator when storing a variable. Try what I have below.

voteevent.OnServerEvent:Connect(function(plrc,num)
            local votevalue=Instance.new("IntValue")
            votevalue.Name="votevalue"
            votevalue.Value=num
            local playervot=plrc.Character

            if allow==true and plrc.Character:FindFirstChild("votevalue") then --I'm assuming "allow" is defined as something, or else it's an unknown variable.
                print("WE DESTROYES"..playervot.votevalue.Value)
                votevalue:Destroy()
            end

            votevalue.Parent=playervot
            print(playervot.votevalue.Value)
            allow=true
        end)

If that doesn't work, it might be the location of the script itself. Tell me any outcomes and I'll be sure to help!

1 comment

0

it helped

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