Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Checking a new StringValue error?

Asked by
Qorm 100
9 years ago

the original String is: "No one!" When the player "claims" the tycoon, it has a loop where it checks which player "owns" it. So the new one says "Player"; so now the "Player" owns the Tycoon. Here's what It's doing..

--this is the dropper script
player=script.Parent.Parent.Parent.OwnerValue.Value
script.Parent.Touched:connect(function(onTouch)
if onTouch:IsA("Part") and onTouch.Name=="d1" then
onTouch:remove()
game.Players(player).Character.IntValue.Value=game.Players.Player.Character.IntValue.Value+10
end
end)

^-- It says this even though the new StringValue is updated to the Tycoon owner. Obviously it tries to get the owner of the tycoon's Character, but it says "No one is not a valid member of Players" which means that It's looking at the original value of the StringValue, and not the new one. This is extremely hard to explain in my perspective and help would be greatly appreciated..

Thanks anyway

1 answer

Log in to vote
1
Answered by 9 years ago

Here are the problems. 1. It isn't [:IsA(](http://wiki.roblox.com/index.php?title=API:Class/Instance/IsA)"Part") 2. You should use :Destroy() instead of :remove() 3. You need to find the player in game.Players. What are the chances that a player named "Player" will play the game?


First, you said :IsA("Part"). It should actually be :IsA("BasePart")


Next, you should use Destroy instead of remove since remove only changes the Parent of what is being removed to nil and not actually being removed.


Lastly, you need to find the player. If the player name is player2 then it wouldn't work. We would need something called :FindFirstChild(). Hoping that the value for "OwnerValue.Value" is a string, :FindFirstChild() checks for Strings or text.


Here is the finished product:

--this is the dropper script
player=script.Parent.Parent.Parent.OwnerValue.Value
script.Parent.Touched:connect(function(onTouch)
if onTouch:IsA("BasePart") and onTouch.Name=="d1" then
onTouch:Destroy()
game.Players:FindFirstChild(player).Character.IntValue.Value=game.Players:FindFirstChild(player).Character.IntValue.Value+10
end
end)

I hope you learned something. (Not hop.)

0
Hopefully this works. Thanks alot! I have learned a few things from that. Qorm 100 — 9y
0
You're welcome! EzraNehemiah_TF2 3552 — 9y
0
`:IsA("Part")` would work, it's just probably not the best answer (since it won't catch other Part-like-objects like Spawns, WedgeParts, etc) BlueTaslem 18071 — 9y
0
@Blue, dang it. I'm never right. EzraNehemiah_TF2 3552 — 9y
Ad

Answer this question