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

How to you make a part that changes your size on touch?

So in my game its supposed to be a family game i'm trying to make a part that changes your size like the one in meepcity. Can someone help me? Here is my script and sorry if your a good scripter and think its stupid.I'm still a beginner at scripting and btw i got a script from somewhere and it made my character either fall or lean back when walking so please make sure it dont do that

script:

script.Parent.Touched:connect(function(part)
   game.Players.LocalPlayer.Character.Humanoid.BodyHeightScale.Value = 0.5
end)

5 comments

0

ok I will help wait a sec

0

Alberto, is your game in r15?

0

yeah its R15

0

Thanks for excepting my answer, I hope if gives you a good understanding of the problem!

0

ewwww use Connect

3 answers

✓ Accepted answer
Script.Parent.Touched:Connect(function(hit)
        If hit.Parent:FindFirstChild(“Humanoid”) then
        game.Workspace[hit.Parent.Name].Humanoid.BodyHeightScale.Value = 0.5
end)

Expiation: In the ruction a have made a variable called hit, so whenever I reference hit it means the thing that was touched. After this I have checked the Parent of the hit to see if it’s a humanoid. After that I went into the workspace and located the character, lowering its height.

I did this on a mobile device so I can not test it.

Also you can only use the local player statement in a local script.

Also make sure this is a sever script.

If you need anymore help just ask.

Also DO NOT ever take scripts from other people, you won’t learn anything!

23 comments

0

Sorry to say but it didn't work

0

Is it in a server script?

0

And was there a error?

0

Also make sure the script is a part

0

Also make sure the script is a part

0

OH i didnt see you say server script

0

Does it work?

0

"Also make sure the script is a part" ok but how do you do that

0

Drag the script into the part is wanted to be touched

0

oh i knew that but the way you said it didn't make sense to me

0

Please do more research in scripting, your lucky that mods have not taken down your question on how easy it is.

0

Try looking at this https://wiki.roblox.com/index.php?title=Developer_Resources then if you can’t work it out then ask a question.

0

"Is it in server script?" i did but how do i know if i touched the brick because it disapears when i put it in server script service

0

Sigh* you create a server script and then put it in a part

0

A server script is the one with nothing on it, it’s just blue

0

Here's some problems, you forgot to put an "end" at the conditional statement. "If" shouldn't be capitalized and instead lower-case like "if". You didn't indent it properly either.

0

She doesn’t understand what I server script is, she’s getting confused

0

Also I did this on an iPad.

0

Thank you it works now

0

i know what server script service is i made a leaderboard script in it but its from alvin blox and a video didnt show what i wanted but a size change

0

No problem, I just recommend doing some more research and messing around with studio to get comfortable with the platform

0

ok

0

hey? you didnt see my answer?

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 --otherPart will be player's body part that touches
	local Humanoid = Character:FindFirstChild("Humanoid")
	if Humanoid then --checks if humanoid exists
		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!

4 comments

0

crap I took too long

0

I wasted all that time

0

oh thank you!

0

Worked

script.Parent.Touched:Connect(function() script.Parent.Size = Vector3.new(x,y,z) wait(2) script.Parent.Size = Vector3.new(x,y,z) end)

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