Still have questions? Join our Discord server and get real time help.
1

# How do I make it so if you are not touching the part anymore you cannot effect it?

This is how the script should work: If you are touching the part and clicking, the size will go down by .01 stud. If you are not touching the part anymore, nothing should happen even when you're clicking.

This is the script:

function onTouch(hit)
mouse.Button1Down:Connect(function()
if hit.Name == "Block" then
hit.Size = hit.Size - Vector3.new(0.01, 0.01, 0.01)
end
end)
end
script.Parent.Touched:Connect(onTouch)


0
gioni01 2055
5 months ago
Edited 5 months ago

## There could be a couple of issues here. Either...

• You're using a Local Script in workspace

• You're attempting to get the player's mouse through a Server Script

Either way, I'll solve those for you here. To accomplish this, you'll simply need to get the local script out of workspace and put it somewhere it can actually run, like StarterPlayerScripts.

--Local Script

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") --wait for remote
local trigger = workspace.Part
local CanScale = false

trigger.Touched:Connect(function(part)
CanScale = true
end)

trigger.TouchEnded:Connect(function(part)
CanScale = false
end)

mouse.Button1Down:Connect(function()
if CanScale then
RemoteEvent:FireServer(trigger) --send the part so we dont have to get it on the server. this just saves you from changing another line of code in case you change the part
end
end)


--Server script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = Instance.new("RemoteEvent") --create remote
RemoteEvent.Parent = ReplicatedStorage

RemoteEvent.OnServerEvent:Connect(function(plr,part) --first parameter always player
part.Size = part.Size - Vector3.new(.01,.01,.01)
end)


Remote Events

## Accept and upvote if this helps!

1
not bad incapaxx 3172 — 5mo
0
thank u brother incatrash gioni01 2055 — 5mo