Ok, so first off, I see that you are using the object LocalPlayer in your script. Since you can only access it in a LocalScript, I am going to assume you are using a LocalScript. This is a big problem (if you are using a LocalScript), because if you use a LocalScript to operate your body scaling content for your game, it will only show the person who touches the part scaled, and others will see them as the size they used to be before they touched the part. This is because anything done in LocalScripts (except for a few exceptions like animations) will not be replicated to the server, at least not properly or in the right way. So here is some advice: Use a ServerScript. That way, it will replicate to all players, not just one player. Another thing is your code is just simply not correct. If you look at the touched event, the part parameter is not being used. Lowercase Connect is also deprecated, you need to be using capitalized Connect. It may not seem like a big deal, but it is. One more thing is that line 2 is not the right way to be scaling the player in a touched event. I will show you a better method. So, this method requires the parameter you put in your function earlier but did not use. This part involves the actual fixing of your code. So, you did use a touched event. That is correct. The code in your touched event was not correct.
So, lets think about the parameter for a moment. As it says on the Roblox Developer Hub, there is a parameter called "OtherPart". If the character's body parts are the ones touching the Basepart, then we reference their entire body and find their humanoid, which we can then scale their body from. So, this is the code:
local BasePart = script.Parent
function Scale(otherPart)
local Character = otherPart.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
if Humanoid then
local HeightScale = Humanoid:FindFirstChild("BodyHeightScale")
HeightScale.Value = 0.5
end
end
BasePart.Touched:Connect(Scale)
This should work. I might have forgot to add something, but other than that it should would. Accept this answer if this helps!
5 comments
ok I will help wait a sec
Alberto, is your game in r15?
yeah its R15
Thanks for excepting my answer, I hope if gives you a good understanding of the problem!
ewwww use Connect